home *** CD-ROM | disk | FTP | other *** search
- unit Bug;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls;
-
- type
- TForm1 = class(TForm)
- ListBox1: TListBox;
- Button1: TButton;
- procedure Button1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- const
- NumberOfItems = 4;
-
- procedure TForm1.Button1Click(Sender: TObject);
- var
- CurrentIndex : integer;
- begin
- CurrentIndex := ListBox1.ItemIndex;
- If CurrentIndex < NumberOfItems then
- Inc(CurrentIndex)
- Else CurrentIndex := 0;
- ListBox1.ItemIndex := CurrentIndex;
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- var
- i : integer;
- begin
- for i := 1 to NumberOfItems do
- ListBox1.Items.Add( 'Item Number: ' + IntToStr(i));
- ListBox1.ItemIndex := 0;
- end;
-
- end.
-